hs.hotkey.bind({ "cmd", "shift" }, "s", function()
	local click_rd = { x = math.random(166, 513), y = math.random(749, 781) }
	-- hs.alert.show(click_rd[1])
	-- hs.alert.show(click_rd[2])
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, click_rd):post()
	hs.timer.usleep(20000)
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, click_rd):post()
	hs.timer.usleep(20000)
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, click_rd):post()
	hs.timer.usleep(250000)
	hs.timer.usleep(250000)
	hs.timer.usleep(250000)
	hs.timer.usleep(250000)
	hs.timer.usleep(250000)
	local down_rd = { x = math.random(161, 196), y = math.random(717, 737) }
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, down_rd):post()
	hs.timer.usleep(20000)
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, down_rd):post()
	hs.timer.usleep(20000)
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, down_rd):post()
	hs.timer.usleep(20000)
	hs.eventtap.event
		.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = math.random(220, 420), y = math.random(717, 737) })
		:post()
	hs.timer.usleep(20000)
	hs.eventtap.event
		.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = math.random(420, 520), y = math.random(717, 737) })
		:post()
	hs.timer.usleep(20000)
	hs.eventtap.event
		.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = math.random(520, 550), y = math.random(717, 737) })
		:post()
	hs.timer.usleep(20000)
	hs.eventtap.event
		.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = math.random(550, 600), y = math.random(717, 737) })
		:post()
	hs.timer.usleep(20000)
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 620, y = 720 }):post()

	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 214, y = 833 }):post()
	-- hs.timer.usleep(2000)
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 214, y = 833 }):post()
	-- hs.timer.usleep(2000)
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 214, y = 833 }):post()
	-- hs.timer.usleep(250000)
	-- hs.timer.usleep(250000)
	-- hs.timer.usleep(250000)
	-- hs.timer.usleep(250000)
	-- hs.timer.usleep(250000)
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 187, y = 774 }):post()
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 187, y = 774 }):post()
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = 552, y = 774 }):post()
	-- hs.timer.usleep(2000)
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 552, y = 773 }):post()

	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 175, y = 727 }):post()
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 175, y = 727 }):post()
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = 513, y = 727 }):post()
	-- hs.timer.usleep(2000)
	-- hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 513, y = 727 }):post()
end)

hs.hotkey.bind({ "cmd", "shift" }, "c", function()
	-- copy id number
	if hs.window.focusedWindow():application():bundleID() == "org.mozilla.firefoxdeveloperedition" then
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1624, y = 222 }):post()
		hs.timer.usleep(20000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1353, y = 374 }):post()
		hs.timer.usleep(20000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 1353, y = 374 }):post()
		hs.timer.usleep(2000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = 1353, y = 374 }):post()
		return
	end
	local point_ori = hs.mouse.absolutePosition()
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1375, y = 59 }):post()
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 1375, y = 59 }):post()
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1375, y = 59 }):post()
	hs.mouse.absolutePosition(point_ori)
end)

-- 774 187
-- 773 552
-- 获取选中文本的核心函数 (AXUIElement 版本)
local function get_selected_text_by_ax()
	local focusedElement = hs.uielement.focusedElement()
	return focusedElement:selectedText()
end
hs.hotkey.bind({ "cmd", "shift" }, "i", function()
	local point = hs.mouse.absolutePosition()
	-- hs.notify.new({ title = "Hammerspoon", informativeText = tostring(point.x) }):send()
	-- hs.notify.new({ title = "Hammerspoon", informativeText = tostring(point.y) }):send()
	hs.alert.show(math.floor(point.x))
	hs.alert.show(math.floor(point.y))

	hs.alert.show(get_selected_text_by_ax())
	-- 1375,58
end)
-- hs.hotkey.bind({ "cmd", "shift" }, "l", function()
-- 	local point_ori = hs.mouse.absolutePosition()
-- 	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1375, y = 59 }):post()
-- 	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 1375, y = 59 }):post()
-- 	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1375, y = 59 }):post()
-- 	hs.mouse.absolutePosition(point_ori)
-- end)

hs.hotkey.bind({ "cmd", "shift" }, "l", function()
	if hs.window.focusedWindow():application():bundleID() == "org.mozilla.firefoxdeveloperedition" then
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1570, y = 154 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 1570, y = 154 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1570, y = 154 }):post()
		hs.timer.usleep(250000)

		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 962, y = 489 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 962, y = 489 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 962, y = 489 }):post()
		hs.timer.usleep(250000)

		hs.eventtap.event.newKeyEvent("down", true):post()
		hs.timer.usleep(250000)
		hs.eventtap.event.newKeyEvent("down", true):post()
		hs.timer.usleep(250000)
		hs.eventtap.event.newKeyEvent("return", true):post()
		hs.timer.usleep(250000)

		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 891, y = 615 }):post()
		hs.timer.usleep(2000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 891, y = 615 }):post()
		hs.timer.usleep(2000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = 1161, y = 616 }):post()
		hs.timer.usleep(2000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1161, y = 616 }):post()
		hs.timer.usleep(2000)

		hs.timer.usleep(250000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1016, y = 672 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 1016, y = 672 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1016, y = 672 }):post()
	end
end)

hs.hotkey.bind({ "cmd", "shift" }, "y", function()
	if hs.window.focusedWindow():application():bundleID() == "org.mozilla.firefoxdeveloperedition" then
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1570, y = 154 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 1570, y = 154 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1570, y = 154 }):post()
		hs.timer.usleep(250000)

		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 962, y = 489 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 962, y = 489 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 962, y = 489 }):post()
		hs.timer.usleep(250000)

		hs.eventtap.event.newKeyEvent("down", true):post()
		hs.timer.usleep(250000)
		hs.eventtap.event.newKeyEvent("return", true):post()
		hs.timer.usleep(250000)

		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 891, y = 615 }):post()
		hs.timer.usleep(2000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 891, y = 615 }):post()
		hs.timer.usleep(2000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = 1161, y = 616 }):post()
		hs.timer.usleep(2000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1161, y = 616 }):post()
		hs.timer.usleep(2000)

		hs.timer.usleep(250000)
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = 1016, y = 672 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = 1016, y = 672 }):post()
		hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = 1016, y = 672 }):post()
	end
end)
local SKU_list = {}
local function copy(x, y, n)
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.mouseMoved, { x = x, y = y }):post()
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDown, { x = x, y = y }):post()
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseDragged, { x = x + 140, y = y }):post()
	hs.eventtap.event.newMouseEvent(hs.eventtap.event.types.leftMouseUp, { x = x + 140, y = y }):post()
	hs.eventtap.keyStroke({ "cmd" }, "c")
	SKU_list["Key_" .. n] = hs.pasteboard.getContents()
end
local function paste(SKU, n)
	for i = 1, n do
		-- hs.eventtap.keyStrokes(SKU["Key_" .. i])
		hs.pasteboard.setContents(SKU["Key_" .. i])
		hs.timer.usleep(50000)
		hs.eventtap.keyStroke({ "cmd" }, "v")
		hs.timer.usleep(100000)
		hs.eventtap.keyStroke({}, "tab")
		hs.timer.usleep(50000)
		hs.eventtap.keyStroke({}, "tab")
		hs.timer.usleep(50000)
		hs.eventtap.keyStroke({}, "tab")
		hs.timer.usleep(50000)
	end
end
hs.hotkey.bind({ "cmd", "shift" }, "6", function()
	if hs.window.focusedWindow():application():bundleID() == "org.mozilla.firefoxdeveloperedition" then
		for i = 1, 6 do
			copy(930, 278 + i * 30, i) -- +30
		end
		hs.eventtap.keyStroke({ "ctrl", "shift" }, "tab")
		paste(SKU_list, 6)
	end
end)

hs.hotkey.bind({ "cmd", "shift" }, "8", function()
	if hs.window.focusedWindow():application():bundleID() == "org.mozilla.firefoxdeveloperedition" then
		for i = 1, 3 do
			copy(930, 278 + i * 36, i) -- +36
		end
		hs.eventtap.keyStroke({ "ctrl", "shift" }, "tab")
		paste(SKU_list, 3)
	end
end)
